package application.translators.impl;

import application.model.ChemicalCompositionModel;
import application.model.ChemicalCompositionsModel;
import application.translators.Translator;
import mappings.ChemicalComposition;

import java.util.List;

public class ChemicalCompositionsTranslator implements Translator<List<ChemicalComposition>, ChemicalCompositionsModel>
{
    @Override
    public ChemicalCompositionsModel translate(List<ChemicalComposition> chemicalCompositions)
    {
        ChemicalCompositionsModel chemicalCompositionsModel = new ChemicalCompositionsModel();

        for(ChemicalComposition chemicalComposition : chemicalCompositions)
        {
            ChemicalCompositionModel chemicalCompositionModel = new ChemicalCompositionModel();
            chemicalCompositionModel.setMax(chemicalComposition.getMax().toString());
            chemicalCompositionModel.setMin(chemicalComposition.getMin().toString());
            chemicalCompositionModel.setShortcut(chemicalComposition.getChemicalElements().getShortcut());

            chemicalCompositionsModel.getChemicalCompositions().add(chemicalCompositionModel);
        }

        return chemicalCompositionsModel;
    }
}
